/**
 *
 * @revision:   $Id: script.js 33 2011-05-17 17:42:03Z agbiggora@gmail.com $
 * @package     Joomla!
 * @since       {SINCE}
 * @subpackage	AG Yandex Metrika
 * @version     {PROJECTVERSION}
 * @description Module add Yandex Metrics code in your website
 * @copyright	Copyright © 2010-{PROJECTYEAR} Alexey Gordeyev IK. All rights reserved.
 * @license     GNU General Public License v2.0
 * @author      ALEXEY GORDEYEV IK
 * @author mail admin@gordejev.lv
 * @website     www.gordejev.lv
 *
 * CODE GENERATED BY: ALEXEY GORDEYEV IK CODE GENERATOR
 * HTTP://WWW.AGJOOMLA.COM/
 *
 */

window.addEvent("domready",function(){
	var tabs = [];
	var options = [];
	var opt_iterator = -1;
	var base_table = $$('div.panel fieldset.panelform ul.adminformlist');

	$$('.before').destroy();
	$$('.after').addClass('ag_btn').set('text','Toggle').removeClass('after');
    $$('.ag_text').each(function(el){ 
       var label = el.getChildren('label');
       el.innerHTML = label.get('text'); 
    });
  
	base_table.each(function(eul,idx_1){ 
       var container = $$('div.panel fieldset.panelform');
       var itr  = 0;
	     eul.getChildren('li').each(function(eli,idx_2){
	        if(eli.getElements('span').length > 0) {
            opt_iterator++;
            tabs[opt_iterator] = eli;
            options[opt_iterator] = [];
            itr = 0;
	        }
	        else {
	           options[opt_iterator][itr] = eli;
	           itr++;
	        }
	     });
	     eul.destroy();
	});

	tabs.each(function(el,idx) {
	     var container = $$('div.panel fieldset.panelform');
	     var div_option = new Element('div',{"class":"ag_option"});
	     var div_options = new Element('div',{"class":"ag_options"});
	     var ul_pane = new Element('ul',{"class":"adminformlist"});
	     
	     
	     options[idx].each(function(li,ind){
	        li.injectInside(ul_pane);
	     });
	     
	     ul_pane.addClass('padd');
	     ul_pane.injectInside(div_options);
	     
	     div_option.innerHTML = el.innerHTML;
	     div_option.injectInside(container[0]);
	     div_options.injectAfter(div_option);
	});
	var div_clr = new Element('div',{"class":"clr border-bottom"});
  div_clr.injectInside($$('div.panel fieldset.panelform')[0]);
  
	new Accordion($$('.ag_option'),$$('.ag_options'),{
		onActive:function(toggler){ toggler.addClass("ag_option active"); },
		onBackground:function(toggler){ toggler.addClass("ag_option"); },
		alwaysHide: true
	});
	
});